﻿@page "/tenant-management/tenants"
@*@attribute [Authorize(TenantManagementPermissions.Tenants.Default)]
*@

@using Microsoft.AspNetCore.Authorization

@using Microsoft.AspNetCore.Components.Forms
@using Volo.Abp.AspNetCore.Components.Web

@using Volo.Abp.UI.Navigation
@inject AbpBlazorMessageLocalizerHelper<AbpTenantManagementResource> LH
@inherits AbpCrudPageBase<ITenantAppService, TenantDto, Guid, GetTenantsInput, TenantCreateDto, TenantUpdateDto>

 <GridContent>
    <AntDesign.Card  >
         <AdminTable   TItem="TenantDto"  Columns="TenantManagementTableColumns"  OnChange="OnDataGridReadAsync"  RemoteDataSource="true"  DataSource="@Entities"  Total="@TotalCount"  PageSize="@PageSize"  PageIndex= "@CurrentPage"   Loading="@Loading" >
            <SearchTemplate>
                  <AntDesign.Form  Model="GetListInput" TModel="GetTenantsInput" Name="advanced_search" Class="ant-advanced-search-form">
                    <AntDesign.Row Gutter="24">
                            <AntDesign.GridCol Span="8"  >
                                <FormItem Label="@(L["Tenants"])" >
                                  <AntDesign.Input @bind-Value="@(context.Filter)" OnPressEnter="SearchEntitiesAsync" OnFocus="SearchEntitiesAsync" Placeholder="placeholder" /> 
                                </FormItem>
                            </AntDesign.GridCol>
                    </AntDesign.Row>
                </AntDesign.Form>
            </SearchTemplate>
            <ToolbarRightButtonTemplate  >
                    <AntDesign.ButtonGroup>
                         <AntDesign.Button Icon="@IconType.Outline.Plus" Type="primary" OnClick="OpenCreateModalAsync" >@L["NewTenant"]</AntDesign.Button>
                         <AntDesign.Button Icon="@IconType.Outline.Search" Type="primary" OnClick=" SearchEntitiesAsync" >查询</AntDesign.Button>
                     </AntDesign.ButtonGroup>
            </ToolbarRightButtonTemplate>
        </AdminTable>
    </AntDesign.Card>
</GridContent>


@if (HasCreatePermission)
{
    <Modal @ref="CreateModal" Title="@L["NewTenant"]" Visible="@CreateModalVisible" OnCancel="@CloseCreateModalAsync" OnOk="CreateEntityAsync">
        <Form
            Layout="@FormLayout.Vertical"
            @ref="@CreateFormRef"
            Model="@NewEntity">

            <FormItem Label="@L["TenantName"]">
                <Input @bind-Value="@context.Name"/>
            </FormItem>
            <FormItem Label="@L["DisplayName:AdminEmailAddress"]">
                <Input @bind-Value="@context.AdminEmailAddress"/>
            </FormItem>
            <FormItem Label="@L["DisplayName:AdminPassword"]">
                <InputPassword @bind-Value="@context.AdminPassword"/>
            </FormItem>

        </Form>
    </Modal>
}

@if (HasUpdatePermission)
{
    <Modal @ref="EditModal" Title="@L["Edit"]" Visible="@EditModalVisible" OnCancel="@CloseEditModalAsync" OnOk="UpdateEntityAsync">
        <Form
            Layout="@FormLayout.Vertical"
            @ref="@EditFormRef"
            Model="@EditingEntity">

            <FormItem Label="@L["TenantName"]">
                <Input @bind-Value="@context.Name"/>
            </FormItem>

        </Form>
    </Modal>
}

@if (HasManageFeaturesPermission)
{
    <FeatureManagementModal @ref="FeatureManagementModal"/>
}


